using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration ;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JobSeekers_experiences : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
             WebConfigurationManager.ConnectionStrings[
               "Database2000"].ConnectionString;
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
        {
            if (!IsPostBack)
            {
                ShowExperience();
            }
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {

        DeleteExperience();
        ShowExperience();
    }
    void ShowExperience()
    {
        SqlServerProvider cls = new SqlServerProvider(connectionString);
        cls.CommandText =  "select ExperienceID,Company, Country ,"
        + " Address ,JobPosition ,Salary " +
        "  from tblJSExperiences" +
        " where UserID='" + Convert.ToString(
        Session.Contents["jsuserid"])
        + "'";
        DataTable dataTable = cls.GetDataTable( );
        GridView1.DataSource = dataTable;
        GridView1.DataBind();
    }
    void DeleteExperience()
    {
        string experienceID = "";
        foreach (GridViewRow item in GridView1.Rows)
        {
            CheckBox checkBox = (CheckBox)item.Cells[0].FindControl("chkExperienceID");
            if (checkBox.Checked)
                experienceID += item.Cells[0].Text + ",";
        }
        if (experienceID != "")
        {
            SqlServerProvider cls = new SqlServerProvider(connectionString);
            cls.CommandText = "delete  from tblJSExperiences" +
            " where UserID='" + Convert.ToString(
            Session.Contents["jsuserid"])
            + "' and experienceID in('" +
            experienceID.Replace(",", "','") + "')";
            cls.ExecuteNonQuery( );
        }
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        Response.Redirect("skills.aspx");
    }
    protected void btnNew_Click(object sender, EventArgs e)
    {
        Response.Redirect("experience.aspx");
    }
}
